using System;
using System.Collections.Generic;
using System.Text;

using System.IO;
using System.Xml;
using System.Xml.Schema;

namespace Winsmarts.PI.Common
{
    public class ProgramInputs
    {
        private string sspURL = String.Empty;
        private bool isValid = false;
        private string mappingFile = String.Empty;
        private string inputsFile = String.Empty;

        public string InputsFile
        {
            get { return inputsFile; }
        }
	
        public string MappingFile
        {
            get { return mappingFile; }
        }
	
        public bool IsValid
        {
            get { return isValid; }
        }

        public string SSPURL
        {
            get { return sspURL; }
        }

        public ProgramInputs(string[] args)
        {
            if (args.Length == 0)
            {
                Trace.PrintHelp();
                return;
            }

            switch (args[0])
            {
                case "-help":
                    Trace.PrintHelp();
                    break;
                case "-mapping":
                case "-url":
                case "-inputs":
                    // We have a valid operation, lets go ahead and process the inputs
                    break;
                default:
                    Trace.WriteLine("Invalid input parameters specified");
                    Trace.PrintHelp();
                    return;
            }

            for (int indexer = 0; indexer < args.Length; indexer = indexer + 2)
            {
                switch (args[indexer])
                {
                    case "-mapping":
                        mappingFile = args[indexer + 1];
                        if (!File.Exists(mappingFile))
                            Trace.WriteLine("Mapping file not found");
                        break;
                    case "-url":
                        sspURL = args[indexer + 1];
                        break;
                    case "-inputs":
                        inputsFile = args[indexer + 1];
                        if (!File.Exists(inputsFile))
                            Trace.WriteLine("Input File not found");
                        break;
                    default:
                        break;
                }
            }

            // So far so good, we have the files, and the SSP URL - doesn't mean the inputs are valid
            if (mappingFile.Length != 0 & inputsFile.Length != 0)
            {
                isValid = true;
            }
            else
            {
                isValid = false;
            }
        }
    }
}
